package zhao.exmaple.watearkDemo;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class WateSensorUDFfliterDemo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<WateSensor> sensorDS = env.fromElements(
                new WateSensor("s1", 1L, 1),
                new WateSensor("s2", 2L, 2),
                new WateSensor("s3", 3L, 3)
        );
//        SingleOutputStreamOperator<WateSensor> so = sensorDS.filter((item) -> {
//            if (item.getId().equals("s1")) {
//                return true;
//            } else {
//                return false;
//            }
//        });
//        SingleOutputStreamOperator<WateSensor> so = sensorDS.filter(new FilterFunction<WateSensor>() {
//            @Override
//            public boolean filter(WateSensor value) throws Exception {
//                return value.getId().equals("s1");
//            }
//        });

        SingleOutputStreamOperator<WateSensor> so = sensorDS.filter(new WateSensorFilterImpl("s1"));

        so.print();
        env.execute();


    }
}
